<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>08 Object.definePropert</title>
</head>

<body>


    <script>
        var obj = {
            name: '小黑',
            age: 22
        }

        obj.name = '小明';
        console.log('obj:', obj);

        Object.defineProperty(obj, 'name', {
            value: '隔壁老王',
            writable: true, //能不能修改
            configurable: true, //能不能删除    true  删除'隔壁老王'   修改为'xx'
            // configurable: false, //能不能删除
            enumerable: true //是否可以循环遍历
        })

        // delete obj.name;  //为true时，删除
        // obj.name = 'xx';  //为true时，修改为'xx'
        console.log('obj:', obj);
    </script>
</body>

</html>